import log4js from 'log4js';

log4js.configure({
  appenders: {
    yuanjian: {
      type: 'file',
      filename: 'logs/yuanjian.log',
      maxLogSize: 10485760,
      backups: 10,
      compress: true,
    },
  },
  categories: {
    default: {
      appenders: ['yuanjian'],
      level: 'info',
    },
  },
});

const logger = log4js.getLogger('yuanjian');

/**
 * 记录日志
 */
export default class Logger {
  static debug(data: any) {
    logger.debug(data);
  }

  static info(data: any) {
    logger.info(data);
  }

  static warn(data: any) {
    logger.warn(data);
  }

  static error(data: any) {
    logger.error(data);
  }
}
